package com.example.springclouduserserver.service;

import com.example.springclouduserserver.dao.UserDao;
import com.example.springclouduserserver.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//这里只使用 @Service 也可以，括号里的内容不影响
@Service("UserService")
public class UserService {

    @Autowired
    private UserDao userDao;

    public User queryUserById(int id){
        return userDao.selectUserById(id);
    }
    public User queryUserByUsername(String username){ return userDao.selectUserByUsername(username); }
    public void addUser1(User user){
        userDao.insertUser1(user.getUsername(),user.getPassword(),user.getPermission(),user.getSalt());
    }
    public void addUser(User user){
        userDao.insertUser(user.getUsername(),user.getRealname(),user.getPassword(),user.getPermission(),user.getSalt(),user.getPhone(),user.getEmail());
    }


}

/*传递多个参数我们可以用 Map 来实现
public List<User> queryUser4(Integer age, Integer start, Integer move){
    Map<String,Object> hashMap=new HashMap<>();
    hashMap.put("age",age);
    hashMap.put("start",start);
    hashMap.put("move",move);
    return userDao.selectById4(hashMap);
}
*/


